export default {
    //v-model 双向绑定  vuex
    updateUserName(state,value){
        state.userInfoUpdate.userName = value;
    },
    updateMobileNo(state,value){
        state.userInfoUpdate.mobileNo = value;
    },
    //
    setCommonAddress(state,data){
        state.commonAddress = data;
    },
    setServiceAddress(state,data){
        state.serviceAddress = data;
    },
    addCommonAddress(state,data){
        let newParams = {
            userName:data.userName,
            address:data.address,
            addressId:data.addressId,
            mobileNo:data.mobileNo,
            status:data.status || 0
        }
        state.commonAddress.push(newParams);
    },
    delCommonAddress(state,params){
        let item = state.commonAddress;
        let index = item.findIndex((i)=>i.addressId == params.addressId);
        item.splice(index,1);
    },
    updateCommonAddress(state,params){
        let item = state.commonAddress;
        if(params.status == 1){
            item.map((i)=>{
                if((i.status == 1)&&(i.addressId != params.addressId)){i.status = 0}
            })
        }
        let index = item.findIndex((i)=>i.addressId == params.addressId);
        let newParams = {
            userName:params.userName,
            address:params.address,
            addressId:params.addressId,
            mobileNo:params.mobileNo,
            status:params.status
        }
        item.splice(index,1,newParams);
    },
    setUserInfo(state,data){
        state.userInfo = data;
    },
    setOrderListData(state,data){
        state.orderListData = data;
    },
    setRechargeData(state,data){
        state.rechargeData = data;
    },
    setRateData(state,data){
        state.rateData = data;
    },
    setRecommondList(state,data){
        state.recommondList = data;
    },
    setSignature(state,data){
        state.signatureData = data;
    },
    setIntegralGoods(state,data){
        state.integralGoods = data;
    },
    setGoodsDetail(state,data){
        state.goodsDetail = data;
    },
    setUserInfoUpdate(state,data){
        state.userInfoUpdate = data;
    }
}